﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WCFThree.Entity
{
    public partial class BaseContext : DbContext
    {
        public BaseContext()
            : base("name=BaseContext")
        {
            //在Wcf中禁用EF的代理类和延迟加载
            this.Configuration.ProxyCreationEnabled = false;
        }

        public virtual DbSet<course> courses { get; set; }
        public virtual DbSet<score> scores { get; set; }
        public virtual DbSet<student> students { get; set; }
        public virtual DbSet<teacher> teachers { get; set; }

        public virtual DbSet<UserInfo> UserInfoes { get; set; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<course>()
                .Property(e => e.cno)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<course>()
                .Property(e => e.tno)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<score>()
                .Property(e => e.sno)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<score>()
                .Property(e => e.cno)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<score>()
                .Property(e => e.degree)
                .HasPrecision(4, 1);

            modelBuilder.Entity<student>()
                .Property(e => e.sno)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<student>()
                .Property(e => e.ssex)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<student>()
                .Property(e => e._class)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<teacher>()
                .Property(e => e.tno)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<teacher>()
                .Property(e => e.profession)
                .IsFixedLength()
                .IsUnicode(false);

            modelBuilder.Entity<teacher>()
                .Property(e => e.tsex)
                .IsFixedLength()
                .IsUnicode(false);
        }
    }
}
